const { Model, DataTypes } = require("sequelize");
const sequelize = require("../app/database");

class User extends Model {}

User.init(
  {
    id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    permission: {
      type: DataTypes.INTEGER,
      allowNull: false,
    },
    username: {
      type: DataTypes.STRING,
      allowNull: false,
      unique: true,
    },
    password: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    name: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    phone: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    email: {
      type: DataTypes.STRING,
    },
    address: {
      type: DataTypes.STRING,
    },
    avatar_url: {
      type: DataTypes.STRING,
    },
    id_number: {
      type: DataTypes.STRING,
    },
    major: {
      type: DataTypes.STRING,
    },
    education: {
      type: DataTypes.STRING,
    },
    professional: {
      type: DataTypes.STRING,
    },
    specialty: {
      type: DataTypes.STRING,
    },
    work_year: {
      type: DataTypes.STRING,
    },
    company: {
      type: DataTypes.STRING,
    },
    cr: {
      type: DataTypes.STRING,
    },
    materials_images: {
      type: DataTypes.STRING,
    },
    register_status: {
      type: DataTypes.INTEGER,
    },
    expert_type: {
      type: DataTypes.STRING,
    },
    expert_grade: {
      type: DataTypes.INTEGER,
    },
    createAt: {
      type: DataTypes.DATE,
    },
    updateAt: {
      type: DataTypes.DATE,
    },
  },
  {
    tableName: "user",
    createdAt: "createAt",
    updatedAt: "updateAt",
    timestamps: true,
    sequelize,
  }
);
module.exports = User;
